package com.huluobo.a2307monthdemo.videos

import androidx.lifecycle.MutableLiveData
import com.huluobo.lib_base.entity.CommentBean
import com.huluobo.lib_base.entity.VideoBean
import com.huluobo.lib_base.mvvm.BaseViewModel
import com.huluobo.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 *  Created by LC on 2025/9/28.
 */
@HiltViewModel
class VideoViewModel @Inject constructor(private val apiService: ApiService) : BaseViewModel() {
    val getVideoSuccess by lazy { MutableLiveData<List<VideoBean>>() }
    fun getVideos(currentPage: Int, pageSize: Int) {
        executeNetwork(
            { apiService.getVideos(currentPage, pageSize) },
            getVideoSuccess::postValue
        )
    }

    val likeVideoSuccess by lazy { MutableLiveData<String>() }
    fun likeVideo(videoId: Int) {
        executeNetwork(
            { apiService.likeVideo(videoId) },
            likeVideoSuccess::postValue
        )
    }

    val unLikeVideoSuccess by lazy { MutableLiveData<String>() }
    fun unLikeVideo(videoId: Int) {
        executeNetwork(
            { apiService.unLikeVIdeo(videoId) },
            unLikeVideoSuccess::postValue
        )
    }

    val followAuthSuccess by lazy { MutableLiveData<String>() }
    fun followAuth(map: Map<String, String>) {
        executeNetwork(
            { apiService.followAuth(mapToJson(map)) },
            followAuthSuccess::postValue
        )
    }

    val getCommentSuccess by lazy { MutableLiveData<List<CommentBean>>() }
    fun getComment(videoId: Int) {
        executeNetwork(
            { apiService.getComment(videoId) },
            getCommentSuccess::postValue
        )
    }
}